﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;



namespace GraphPainterASP.NET.Controllers
{

    public class Graph
    {
        public double Max;
        public double Min;
        public double Average;
        public List<GraphValues> Values;

        public Graph(List<GraphValues> Values_Temp)
        {
            Values = Values_Temp;
        }
        public void SetValues()
        {
            Max = GetMax();
            Min = GetMin();
            Average = GetAverage();
        }
        private double GetMax()
        {
            double Max = Values[0].Max;
            for (int i = 1; i < Values.Count; i++)
                if (Values[i].Max > Max)
                    Max = Values[i].Max;
            return Max;
        }
        private double GetMin()
        {
            double Min = Values[0].Min;
            for (int i = 1; i < Values.Count; i++)
                if (Values[i].Min < Min)
                    Min = Values[i].Min;
            return Min;
        }
        private double GetAverage()
        {
            double Total = Values[0].Average;
            for (int i = 1; i < Values.Count; i++)
                Total += Values[i].Average;
            return (double)(Total / Values.Count);
        }

    }

}